﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
 
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Demo
{
    public partial class Chart : DemoBaseUserControl
    {
        public Chart()
        {
            InitializeComponent();
        }

        private void Chart_Load(object sender, EventArgs e)
        {
            this.Title = "图表";
            this.Description = "Spread .NET  提供了丰富的图表类型，用户可以用 Spread 设计器去自定义图表，本例中点击下面的按钮"+
                "启动 Spread 设计器设计自己的图表，还可以在图表上点击右键选择图表设计器进行自定义图表。";

            //string defaultCommonPath = System.IO.Path.Combine(Application.StartupPath, "..\\..\\Resources\\");// default XML path
            //string commonPath = defaultCommonPath;

            //Microsoft.Win32.RegistryKey commonKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey("FarPoint.Win.Spread\\Resources");
            //if (commonKey != null)
            //{
            //    object commonPathObj = commonKey.GetValue("v52005", defaultCommonPath);
            //    commonPath = commonPathObj is string ? (string)commonPathObj : defaultCommonPath;
            //}

            //string xmlFile = System.IO.Path.Combine(System.IO.Path.Combine(commonPath, "ChartXml"), "Chart.xml");

            string s = global::Demo.Properties.Resources.chart;

            byte[] bs = Encoding.UTF8.GetBytes(s);
            Stream st = new MemoryStream(bs);
            this.fpSpread1.Open(st);
            
            this.fpSpread1.ActiveSheet.Columns.Count = 14;
            this.fpSpread1.ActiveSheet.Rows.Count = 60;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FarPoint.Win.Spread.Design.DesignerMain design = new FarPoint.Win.Spread.Design.DesignerMain(this.fpSpread1);
            design.ShowDialog();
        }

        private void fpSpread1_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
